package com.group.eams.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.group.eams.pojo.dto.FixedAssetCategoryQueryDto;
import com.group.eams.pojo.entity.FixedAssetCategory;
import com.group.eams.service.FixedAssetCategoryService;
import com.group.eams.mapper.FixedAssetCategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author 恩哲欣
* @description 针对表【fixed_asset_category(固定资产分类表)】的数据库操作Service实现
* @createDate 2024-10-29 16:09:34
*/
@Service
public class FixedAssetCategoryServiceImpl extends ServiceImpl<FixedAssetCategoryMapper, FixedAssetCategory> implements FixedAssetCategoryService{

    @Autowired
    private FixedAssetCategoryMapper fixedAssetCategoryMapper;
    /**
     * 根据查询条件查询固定资产分类列表
     *
     * @param fixedAssetCategoryQueryDto 查询条件
     * @return 固定资产分类列表
     */
    @Override
    public Page<FixedAssetCategory> findByQueryDto(FixedAssetCategoryQueryDto fixedAssetCategoryQueryDto) {
        Page<FixedAssetCategory> page = new Page<>(fixedAssetCategoryQueryDto.getPage(), fixedAssetCategoryQueryDto.getLimit());
        LambdaQueryWrapper<FixedAssetCategory> queryWrapper = new LambdaQueryWrapper<>();

        queryWrapper.like(!StrUtil.isEmpty(fixedAssetCategoryQueryDto.getName()),FixedAssetCategory::getName,fixedAssetCategoryQueryDto.getName())
                .like(!StrUtil.isEmpty(fixedAssetCategoryQueryDto.getCode()),FixedAssetCategory::getCode,fixedAssetCategoryQueryDto.getCode())
                .eq(fixedAssetCategoryQueryDto.getStatus() != null,FixedAssetCategory::getStatus,fixedAssetCategoryQueryDto.getStatus());
        return fixedAssetCategoryMapper.selectPage(page, queryWrapper);
    }
}
